{include file="public/header" /}
<style>
    .time{
        width: 33.33% !important;
    }
    .flex-layout .time:nth-child(2){
        text-align: center !important;
    }
    .flex-layout .time:nth-child(3){
        text-align: right !important;
    }
</style>
<body class="bgc">
<div class="header">
    <span class="layui-icon layui-icon-left" onclick="load_href('{:url(\'user/index\')}',2)"></span> 我的发布
</div>

<ul class="pro-list-nav-top">
    <li data-type="1" class="{if $Request.param.type == 1 ||  !$Request.param.type}active{/if}">
        <div>买单</div>
        <p></p>
    </li>
    <li data-type="2" class="{if $Request.param.type == 2}active{/if}">
        <div>卖单</div>
        <p></p>
    </li>
</ul>
<ul class="pro-list-nav">
    <li data-status="" class="{if !$Request.param.status}active{/if}">
        <div>全部</div>
        <p></p>
    </li>
    <li data-status="1" class="{if $Request.param.status == 1}active{/if}">
        <div>交易中</div>
        <p></p>
    </li>
    <li data-status="2" class="{if $Request.param.status == 2}active{/if}">
        <div>已完成</div>
        <p></p>
    </li>
    <li data-status="3" class="{if $Request.param.status == 3}active{/if}">
        <div>已撤销</div>
        <p></p>
    </li>
</ul>

<ul class="my-order-list tpl_list">

</ul>
<script id="template" type="text/html">


    {{# for(var i=0;i < d.data.length ;i++){ }}
    <li>
        <p class="flex-layout">发布时间：{{d.data[i].create_time}}<span>{{d.data[i].statusText}}</span></p>
        <div class="b flex-layout" style="height: 1.5rem !important;">
            <div class="time">单价：{{d.data[i].price}}</div>
            <div class="time">数量：{{d.data[i].num}}</div>
            <div class="time">总价：{{d.data[i].money}}</div>
        </div>
        <div class="b flex-layout" style="height: 1.5rem !important;">
            <div class="time">剩余数量：{{d.data[i].end_num}}</div>
            <div class="time">剩余总价：{{d.data[i].end_money}}</div>
            <div class="time"></div>
        </div>
        <div class="order-btn">
            <a href="javascript:;" class="getdetail"  data-id="{{d.data[i].id}}" >交易详情</a>
            {{# if(d.data[i].status == 1){ }}
                <a href="javascript:;" class="bc clearOrder" data-id="{{d.data[i].id}}">撤单</a>
            {{# } }}
        </div>
    </li>
    {{# } }}

</script>
</body>
{include file="public/footer"/}
<script>
    $(function () {
        getFlowList('{$Request.param.type?:1}','{$Request.param.status?:""}', "{:url('deal/getDealPublish')}");
        $('.pro-list-nav-top li').click(function () {
            $(this).addClass('active').siblings().removeClass('active');
            getDealList($(this).attr('data-type'),$(".pro-list-nav .active").attr('data-status'));
        });
        $('.pro-list-nav li').click(function () {
            $(this).addClass('active').siblings().removeClass('active');
            getDealList($(".pro-list-nav-top .active").attr('data-type'),$(this).attr('data-status'));
        });
        function getDealList(type,status){
            $(".tpl_list").empty();
            getFlowList(type,status, "{:url('deal/getDealPublish')}");
        }
        
        $('.tpl_list').on('click', '.getdetail', function () {
            var id = $(this).attr('data-id');
            window.location.href = "{:url('deal/my_deal_detail')}?id="+id+"&type="+$(".pro-list-nav-top .active").attr('data-type')+"&status="+$(".pro-list-nav .active").attr('data-status');
        });
        $('.tpl_list').on('click', '.clearOrder', function () {
            var id = $(this).attr('data-id');
            layer.confirm('确定要撤销吗？', {title: '请确认'}, function () {
                $.post('{:url("deal/repeal")}', {id:id}, function (data) {
                    layer.closeAll();
                    layer.msg(data.msg);
                    if (data.code == 1) {
                        $(".tpl_list").empty();
                        getDealList($(".pro-list-nav-top .active").attr('data-type'),$(this).attr('data-status'));
                    }
                });
            });
        });
    })
</script>
</html>